package com.renjian.model;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

import com.renjian.tool.UserHandler;

public class User {
	public String id;
	public String name;
	public String screen_name;
	public String description;
	public String profile_image_url;
	public String url;
	public String isProtected;
	public String created_at;
	public String followers_count;
	public String following_count;
	public String favourites_count;
	public String is_followed_me;
	public String is_following;
	public String score;
	public String gender;

	public void xmlToUser(String ret) throws SAXException, IOException {
		InputStream iStream = new ByteArrayInputStream(ret.getBytes());
		InputSource iSource = new InputSource(iStream);
		XMLReader myReader = XMLReaderFactory.createXMLReader();
		ContentHandler handler = new UserHandler();
		myReader.setContentHandler(handler);
		myReader.parse(iSource);

	}

	public String toString() {

		return "id:" + id + ",name:" + name + ",screen_name:" + screen_name
				+ ",description:" + description + ",profile_image_url:"
				+ profile_image_url + ",url:" + url + ",isProtected:"
				+ isProtected + ",created_at:" + created_at
				+ ",followers_count:" + followers_count + ",following_count:"
				+ following_count + ",favourites_count:" + favourites_count
				+ ",is_followed_me:" + is_followed_me + ",is_following:"
				+ is_following + ",score:" + score + ",gender:" + gender;
	}

}
